package com.kitty.game.shop;

import com.kitty.game.config.Medicine;
import com.kitty.game.config.PetShop;

import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class ShopDataPool {

    private static Map<String, Medicine> name2Medicine;

    private static Set<String> recoveMpMedicines;

    private static Map<String, PetShop> name2PetShop;


    public static void initMedicineData(List<Medicine> list ) {
        Map<String, Medicine> name2MedicineMap = new HashMap<>();
        Set<String> recoveMpMedicineSet = new HashSet<>();
        for (Medicine medicine : list) {
            name2MedicineMap.put(medicine.getKey_name(), medicine);
            if (medicine.getRecover_mana() > 0) {
                recoveMpMedicineSet.add(medicine.getKey_name());
            }
        }
        name2Medicine = name2MedicineMap;
        recoveMpMedicines = recoveMpMedicineSet;
    }

    public static Medicine getMedicineBy(String name) {
        return name2Medicine.get(name);
    }

    public static Set<String>  getRecoveMpMedicines() {
        return recoveMpMedicines;
    }


    public static void initPetShopData(List<PetShop> list){
        Map<String, PetShop> name2PetShop =new HashMap<>(list.size());
        for (PetShop petShop: list){
            name2PetShop.put(petShop.getName(),petShop);
        }
        ShopDataPool.name2PetShop =name2PetShop;
    }


    public static Map<String, PetShop> getName2PetShop() {
        return name2PetShop;
    }


    public static PetShop getPetShopByName(String name){
       return name2PetShop.get(name);
    }

}
